﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using FeedAgregator;

public partial class Redirect : System.Web.UI.Page
{
    public int FeedItemId { get; set; }


    protected void Page_Load(object sender, EventArgs e)
    {
        foreach (string key in Request.QueryString)
        {
            switch (key.ToLower())
            {

                case "itemid":
                    FeedItemId = int.Parse(Request.QueryString[key]);
                    break;
                default:
                    break;
            }
        }

        using (FeedSignalDataContext ctx = new FeedSignalDataContext())
        {
            FeedItem item = (from feedItems in ctx.FeedItems
                             where feedItems.ID == FeedItemId
                             select feedItems).SingleOrDefault();
            Response.Redirect(item.ItemUrl);
        }
    }
}
